<?php
if(!defined('PCFINAL')) exit('Request Error!');
$system_version = '4.0-20210808';
$result = sql_query('select * from cms_system where id = 1');
$row = sql_fetch_array($result);
$system_template = $row['s_template'];
$system_mtemplate = $row['s_mtemplate'];
$system_domain = $row['s_domain'];
$system_mdomain = $row['s_mdomain'];
$system_name = $row['s_name'];
$system_seoname = $row['s_seoname'];
$system_title = ($system_seoname == '') ? $system_name : $system_seoname.' - '.$system_name ;
$system_keywords = $row['s_keywords'];
$system_description = $row['s_description'];
// $system_copyright = $row['s_copyright'].'<p class="ar f12">网站程序：<a href="http://www.pcfinal.cn" target="_blank">凡诺广告传媒</a></p>';
$system_copyright = $row['s_copyright'].'';
$system_mcopyright = $row['s_mcopyright'];
$system_hotkeywords = $row['s_hotkeywords'];
$system_feedback = $row['s_feedback'];
$system_phone = $row['s_phone'];
$system_qq = $row['s_qq'];
$system_qrcode = $row['s_qrcode'];
$system_weixin = $row['s_weixin'];
$system_weibo = $row['s_weibo'];
$system_mode = $row['s_mode'];
$system_p1 = $row['s_p1'];
$system_p2 = $row['s_p2'];
$system_p3 = $row['s_p3'];
$system_p4 = $row['s_p4'];
$system_thumbnail = $row['s_thumbnail'];
$system_theight = $row['s_theight'];
$system_twidth = $row['s_twidth'];
$system_slideshow = ($row['s_slideshow'] == 0) ? 9999 : $row['s_slideshow'] ;

$s_path = '';
$t_path = '/template/'.$system_template.'/';
$t_mpath = '/template/'.$system_mtemplate.'/';
$result = sql_query('select * from cms_template where t_path = "'.$system_template.'" ');
if ($row = sql_fetch_array($result)){
	$system_logo = $row['t_logo'];
}
$result = sql_query('select * from cms_template where t_path = "'.$system_mtemplate.'" ');
if ($row = sql_fetch_array($result)){
	$system_mlogo = $row['t_logo'];
}
$system_closem = true;
//判断是否是移动设备
function ism() {
	global $system_mdomain;
	global $system_closem;
	$ism = false;
	if (isset($_SERVER['HTTP_X_WAP_PROFILE'])) {
		$ism = true;
	}
	if (isset($_SERVER['HTTP_VIA'])) {
		$ism = (stristr($_SERVER['HTTP_VIA'], "wap") ? true : false);
	}
	if (isset($_SERVER['HTTP_USER_AGENT'])) {
		$clientkeywords = array('nokia','sony','ericsson','mot','samsung','htc','sgh','lg','sharp','sie-','philips','panasonic','alcatel','lenovo','iphone','ipod','ipad','blackberry','meizu','android','netfront','symbian','ucweb','windowsce','palm','operamini','operamobi','openwave','nexusone','cldc','midp','wap','mobile');
		if (preg_match('/(' . implode('|', $clientkeywords) . ')/i', strtolower($_SERVER['HTTP_USER_AGENT']))) {
			$ism = true;
		}
	}
	if (isset($_SERVER['HTTP_ACCEPT'])) {
		if ((strpos($_SERVER['HTTP_ACCEPT'], 'vnd.wap.wml') !== false) && (strpos($_SERVER['HTTP_ACCEPT'], 'text/html') === false || (strpos($_SERVER['HTTP_ACCEPT'], 'vnd.wap.wml') < strpos($_SERVER['HTTP_ACCEPT'], 'text/html')))) {
			$ism = true;
		}
	}
	if ('http://'.$_SERVER['SERVER_NAME'].'' == $system_mdomain) {
		$ism = true;
	}
	if ($system_closem) {
		$ism = false;
	}
	return $ism;
}
//频道链接地址
function c_url($t0){
	global $system_mode;
	global $s_path;
	return (( $system_mode == 2 ) ? $s_path.'/channel-'.$t0.'-1.html' : $s_path.'/channel.php?id='.$t0.'');
}
//详情链接地址
function d_url($t0){
	global $system_mode;
	global $s_path;
	return (( $system_mode == 2 ) ? $s_path.'/detail-'.$t0.'.html' : $s_path.'/detail.php?id='.$t0.'');
}

//频道列表
function channel_list($t0,$t1){
	$tmp = '';
	$result = sql_query('select * from cms_channel where c_parent = '.$t0.' order by c_order asc , id asc ');
	while ($row = sql_fetch_array($result)){
		$tmp .= '<li><a '.($row['id'] == $t1 ? ' class="current"' : '').' href="'.c_url($row['id']).'" target="'.$row['c_target'].'">'.$row['c_name'].'</a></li>';
	}
	return $tmp;
}

function channel_dlist ($t0){
	$tmp = '';
	$result = sql_query('select * from cms_channel where c_parent = '.$t0.' order by c_order asc , id asc ');
	while ($row = sql_fetch_array($result)){
		$tmp .= '<div class="hd"><a href="'.c_url($row['id']).'" target="'.$row['c_target'].'">'.$row['c_name'].'</a></div>';
		$tmp .= '<div class="bd"><ul>';
			$results = sql_query('select * from cms_channel where c_parent = '.$row['id'].' order by c_order asc , id asc ');
			while ( $rows = sql_fetch_array($results) ) {
				$tmp .= '<li><a href="'.c_url($rows['id']).'" target="'.$rows['c_target'].'">'.$rows['c_name'].'</a></li>';
			}
		$tmp .= '</ul></div>';
	}
	return $tmp;
}

//频道和内容页的当前位置
function current_location($t0,$t1){
	$tmp = '';
	$result = sql_query('select * from cms_channel where id = '.$t0.'');
	while($row = sql_fetch_array($result)){
		$current = ($row['id'] == $t1 ? 'class ="current"' :'');
		$tmp = '<a '.$current.' href="'.c_url($row['id']).'">'.$row['c_name'].'</a>';
		if($row['c_parent'] <> 0){
			$tmp = current_location($row['c_parent'],$t1).' > '.$tmp;
		}
	}
	return $tmp;
}

//获取频道字段
function get_channel($t0,$t1){
	$result = sql_query('select * from cms_channel where id='.$t0.'');
	if (!!$row = sql_fetch_array($result)){
		return $row[$t1];
	}else{
		return '不存在';
	};
}

//获取碎片内容
function get_chip($t0){
	$result = sql_query('select * from cms_chip where id='.$t0.'');
	if (!!$row = sql_fetch_array($result)){
		return $row['c_content'];
	}else{
		return '';
	};
}

?>